package simpleSort;

import lombok.Data;

@Data
public class Student implements Comparable<Student>{

    private String name;
    private int score;

    public Student(String name, int score) {
        this.name = name;
        this.score = score;
    }

    @Override
    public int compareTo(Student another) {
//        if(another==null){
//            return 0;
//        }
//        if (this.score < another.score){
//            return -1;
//        }else if (this.score > another.score){
//            return 1;
//        }else {
//            return 0;
//        }
        return this.score - another.score;
    }

    @Override
    public String toString(){
//      String s = "student : name :";
//      s += this.getName();
//      s += ", score: ";
//      s += this.getScore();
//      return s;
        return String.format("Student(name: %s, score: %d)", name, score);
    }
}
